package com.www.applyword.ui.my;

import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;

import com.www.applyword.Constants.Constants;
import com.www.applyword.R;
import com.www.applyword.base.BaseActivity;
import com.www.applyword.bean.WXPayBean;
import com.www.applyword.http.CallBack;
import com.www.applyword.http.HttpClient;
import com.www.applyword.utils.SPUtil;
import com.www.applyword.utils.Utils;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * author : huang
 * date   : 2019/11/14 0014 18:02
 * version: 1.0
 */
public class WithdrawActivity extends BaseActivity {
    @BindView(R.id.et_zhanghao)
    EditText etZhanghao;
    @BindView(R.id.et_zhanghao_name)
    EditText etZhanghaoName;
    @BindView(R.id.tv_all)
    TextView tvAll;
    @BindView(R.id.et_input_recharge_money)
    EditText etInputRechargeMoney;
    @BindView(R.id.tv_money)
    TextView tvMoney;

    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.withdraw_activity);
        setTitle("佣金提现");
        setRringTitle("提现");
        tvMoney.setText("￥" + getIntent().getStringExtra("money"));
        tv_right.setOnClickListener(v -> {
            if (TextUtils.isEmpty(etZhanghao.getText().toString().trim())) {
                Utils.showToastSafe("请输入支付宝帐号");
                return;
            }
            if (TextUtils.isEmpty(etZhanghaoName.getText().toString().trim())) {
                Utils.showToastSafe("请输入支付宝姓名");
                return;
            }
            if (TextUtils.isEmpty(etInputRechargeMoney.getText().toString().trim())) {
                Utils.showToastSafe("请输入提现金额");
                return;
            }

            if (Double.parseDouble(etInputRechargeMoney.getText().toString().trim()) <= 10) {
                Utils.showToastSafe("提现金额不能小于10元");
                return;
            }

            Map<String, Object> params = new HashMap<>();
            params.put("Record_UserID", SPUtil.getString(Constants.USERID));
            params.put("Record_Money", etInputRechargeMoney.getText().toString().trim());
            params.put("Record_Type", "0");
            params.put("Record_RecordType", "1");
            params.put("Record_AccountNumber", etZhanghaoName.getText().toString().trim());
            params.put("Record_RealName", etZhanghao.getText().toString().trim());
            HttpClient.post(WithdrawActivity.this, Constants.ADDRECORD, params, new CallBack<WXPayBean>() {
                @Override
                public void onSuccess(WXPayBean wayPay) {
                    Utils.showToastSafe("提交成功");
                    finish();
                }
            });
        });
    }

    @Override
    protected void loadData() {

    }



    @OnClick(R.id.tv_all)
    public void onViewClicked() {
        etInputRechargeMoney.setText(getIntent().getStringExtra("money"));
    }
}
